package whf.framework.config;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import whf.framework.log.Log;
import whf.framework.log.LogFactory;

/**
 * @author wanghaifeng
 *
 */
public class PropertiesConfiguration extends BaseConfiguration{

	private static Log log = LogFactory.getLog(PropertiesConfiguration.class);
	
	public PropertiesConfiguration(String config) throws ConfigurationException{
		try{
			this.configuration = new org.apache.commons.configuration.PropertiesConfiguration(config);
		}catch(Exception e){
			log.error(this, e);
			throw new ConfigurationException(e);
		}
	}
	
	public PropertiesConfiguration(URL config) throws ConfigurationException{
		try{
			this.configuration = new org.apache.commons.configuration.PropertiesConfiguration(config);
		}catch(Exception e){
			log.error(this, e);
			throw new ConfigurationException(e);
		}
	}
	
	public List<String> getIncList(String key) {
		List<String> list = new ArrayList<String>();
		for(int i=0;i<100;i++){
			String s = getString(key+i);
			if(s != null){
				list.add(s);
			}
		}
		return list;
	}
}
